//1.引入express模块，并初始化 express对象
const express = require('express')

const path = require('path')
//2.使用构造函数构造 express 实例
const app = express()

//4.响应前端 http 请求的url
//get
app.get('/',(req,res)=>{
    console.log('这是前端发过来的请求')
    res.send('this is a response')
});

//3.设置监听端口（express 默认端口是3000）和IP  (IP 默认是127.0.0.1)
let server = app.listen(3001,'127.0.0.1',() => {
    let host = server.address().address;
    let post = server.address().port;
    console.log(`APP listening ${host} on post ${post}!`);
});